package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.model.Teacher;
import com.zr.gdms.model.User;
import com.zr.gdms.service.TeacherInfoService;
import com.zr.gdms.serviceimpl.TeacherInfoServiceImpl;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 *  教师信息管理控制层
 * @author xiaRenAn
 */
public class TeaInfoControllerXRA extends HttpServlet{
	TeacherInfoService tser = new TeacherInfoServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
	    doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//字符编码设置
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		//构造session对象
		HttpSession session = req.getSession();
	    //从session对象中取出管理员信息
		User u=(User) session.getAttribute("user"); 
		List<Teacher> uid = tser.allTeacherinfoByUid(u.getUid());
	    JSONArray jso = JSONArray.fromObject(uid);
	    PrintWriter pw = resp.getWriter();
	    pw.write(jso.toString());
	    pw.flush();
	    pw.close();
	
	}
}
